#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=1e5+10;
int a[N];
int a1[N];
int a2[N];
int max1[N],max2[N];
void solve()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a1[i]=a[i]-(n-i);
		a2[i]=a[i]-i+1;
	}
	max2[n+1]=-114514999;
	max1[0]=-114514999;
	for(int i=1;i<=n;i++)
	{
		max1[i]=max(max1[i-1],a1[i]);
	}
	for(int i=n;i>=1;i--)
	{
		max2[i]=max(max2[i+1],a2[i]);
	}
	int ans=0;
	for(int i=2;i<n;i++)
	{
		int b1=max1[i-1]+n-i;
		int b2=max2[i+1]+i-1;
		ans=max(ans,b1+b2+a[i]);
	}
	cout<<ans<<endl;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}

	return 0;
}

